<!DOCTYPE html>
<!--
 *  创建时间: 2020-08-06-15:42
 *  作   者: lpc
 *  Email : lpc@hll520.cn
-->
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>个人中心</title>
    <!-- JQuery -->
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <!-- Bootstrap核心CSS和JS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
        $(function () {
            /* 获取当前空间的信息 */
            $.getJSON(
                location.href+"/getInfo",
                {},
                function (json) {
                    if(json.statusCode===302){
                        alert("请登录！"+json.msg);
                        location.href="/login";
                        return false;
                    }else if(json.statusCode!==200){
                        alert("获取当前用户空间失败！"+json.msg);
                        return false;
                    }
                    let data=json.data;
                    document.title =data.username+"-个人中心";
                    $("#pathName").html(data.username);
                    $("#webName").html(data.realname+"的个人空间");
                    $("#uname").html(data.username);
                    $("#uid").html(data.userid);
                    $("#urealname").html(data.realname);
                }
            );

            /* 获取登录的用户信息 */
            $.getJSON(
                "/user/getInfo",
                {},
                function (json) {
                    if (json.statusCode !== 200) {

                    } else {
                        $("#nav_login").html(`
                        <a href="/space">
                        <span class="glyphicon glyphicon-user"></span>
                        <span id="userName">${json.data.realname}</span></a>
                        `);

                        $("#nav_register").html(`
                    <a href="/user/signOut">安全退出</a>
                    `);

                    }
                },
                "json"
            );
        })

        /* 搜索 */
        function search() {
            let key = $("#key").val();
            location.href = "/goods/search/" + key;
        }
    </script>
</head>
<body>
<div class="container">

    <!-- 导航 -->
    <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1"><span
                    class="sr-only">WTUShop导航栏</span><span class="icon-bar"></span><span
                    class="icon-bar"></span><span class="icon-bar"></span></button>
            <a class="navbar-brand" href="/">WTUShop</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <!-- 左边 -->
            <ul class="nav navbar-nav">
                <li><a href="/goods/search">商场</a></li>
                <li><a href="/kill/list">秒杀活动</a></li>
                <li class="active"><a href="/space/">个人中心</a></li>
                <li><a href="/admin/manage">控制台</a></li>
            </ul>
            <!-- 右边 -->
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/shopping/list">购物车</a></li>
                <li><a href="/order/list">订单查询</a></li>
                <li id="nav_login"><a href="/login"><span
                        class="glyphicon glyphicon-user"></span><span id="userName">请登录</span></a></li>
                <li id="nav_register"><a href="/register">注册</a></li>
                <li>&nbsp;&nbsp;</li><!-- 占位符 -->
            </ul>
        </div>

    </nav>
    <!-- 标题和搜索 -->
    <div class="row clearfix page-header">
        <div class="col-md-8 column">
            <a href="#"><h1 id="webName">Admin的个人中心</h1></a>
        </div>

        <div class="input-group col-md-4 column " style="margin-top: 20px">
            <input type="text" class="form-control" placeholder="搜索商品" id="key">
            <span class="input-group-btn">
                <a href="javaScript:search()">
                <button id="btn_search" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 搜索
                </button>
                    </a>
                    &nbsp;
            </span>
        </div>
    </div>

    <ul class="breadcrumb">
        <li><a href="/space">个人中心</a></li>
        <li class="active" id="pathName">我的空间</li>
    </ul>

    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="row clearfix">


                <div class="col-md-6 column">
                    <img alt="140x140" id="userImg"
                         src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1596710191260&di=657108dc62a9f80206738f86e1c121c7&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F94af721540025e8919280387fb1095296c70aee475a37-rf1w3v_fw658"
                         class="img-circle"
                         style="width: 100%;"
                    />
                </div>


                <div class="col-md-6 column text-left">
                    <div class="jumbotron">
                        <h3 id="uname">名称正在加载中</h3>
                        <p>UID:<span id="uid">99999</span></p>
                        <p>姓名:<span id="urealname">sdjk</span></p>
                        <p><a class="btn btn-primary btn-lg"
                              href="/space/edit" role="button">编辑资料</a></p>
                    </div>

                </div>
            </div>
        </div>


        <div class="col-md-6 column">
            <!-- nav nav-sidebar  -->
            <div class="list-group">
                <a class="list-group-item" href="/home" target="_view">搜索商品</a>
                <a class="list-group-item" href="/kill" target="_view">秒杀促销</a>
                <a class="list-group-item" href="/order/list" target="_view">订单列表</a>
                <a class="list-group-item" href="/shopping/list" target="_view">购物车</a>
                <a class="list-group-item" href="/admin/manage" target="_view">后台管理</a>
                <a class="list-group-item" href="javascript:top.location.href='/user/signOut'">
                    <button style="width: 100%" class="btn btn-danger">退出登录</button>
                </a>
            </div>

        </div>
        <div class="row clearfix">
            <div class="col-md-12 column">
            </div>
        </div>
    </div>
</div>
</body>
</html>